package com.gy.smart.home.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gy.smart.R;
import com.gy.smart.home.bean.DynamicListBean;

import java.util.List;

/**
 * Created by 高岳 on 2017/1/4.
 * Describe:
 */
public class DynamicAdapter extends BaseAdapter {

    private Context context;
    private List<DynamicListBean> lists;

    public DynamicAdapter(Context context,List<DynamicListBean> lists){
        this.context = context;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.adapter_dynamic_layout,null);
            holder.tvTitle = (TextView) convertView.findViewById(R.id.adapter_dynamic_tv_title);
            holder.tvTime = (TextView) convertView.findViewById(R.id.adapter_dynamic_tv_time);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvTitle.setText(lists.get(position).title+"");
        holder.tvTime.setText(lists.get(position).create_time+"");
        return convertView;
    }

    class ViewHolder{
        TextView tvTitle,tvTime;
    }
}
